﻿using System.Linq.Expressions;

namespace ZH.Service.Interface
{

    public interface I_Base_EFCore<T> where T : class, new()
    { /// <summary>
      /// 添加单个
      /// </summary>
      /// <param name="t"></param>
        void Add(T t);
        /// <summary>
        /// 添加多个
        /// </summary>
        /// <param name="ie"></param>
        void AddRange(IEnumerable<T> ie);
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="t"></param>
        void Delete(T t);
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ie"></param>
        void DeleteRange(IEnumerable<T> ie);

        /// <summary>
        /// 单个修改
        /// </summary>
        /// <param name="t"></param>
        void Update(T t);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="ie"></param>
        void UpdateRange(IEnumerable<T> ie);
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>

        int SaveChanges();
        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll(Expression<Func<T, bool>>? where = null);
        /// <summary>
        /// 排序条件查询
        /// </summary>
        /// <typeparam name="t"></typeparam>
        /// <param name="isAsc"></param>
        /// <param name="order"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll<t>(bool isAsc = true, Expression<Func<T, t>>? order = null, Expression<Func<T, bool>>? where = null);
        /// <summary>
        /// 分页排序条件查询
        /// </summary>
        /// <typeparam name="t">排序类型</typeparam>
        /// <param name="total">输出总条数</param>
        /// <param name="page">页码</param>
        /// <param name="limit">每一页数量</param>
        /// <param name="isAsc">升序/降序</param>
        /// <param name="order">排序条件</param>
        /// <param name="where">查询条件</param>
        /// <returns></returns>
        IQueryable<T> QueryAll<t>(out int total, int page = 1, int limit = 10, bool isAsc = true, Expression<Func<T, t>>? order = null, Expression<Func<T, bool>>? where = null);
    }

}
